package com.zhoutao.blog.seven.model;

import lombok.Data;

import java.util.List;

@Data
public class AdminTableResp<T> {

    private int code;

    private String msg;

    private long count;

    private List<T> data;

    public static <T> AdminTableResp<T> success(List<T> list) {
        return new AdminTableResp<T>()
                .setCode(0)
                .setMsg("")
                .setCount(list.size())
                .setData(list);
    }

    public static <T> AdminTableResp<T> success(PageList<T> articlePageList) {
        return new AdminTableResp<T>()
                .setCode(0)
                .setMsg("")
                .setCount(articlePageList.getTotal())
                .setData(articlePageList.getData());
    }
}
